<?php

Class Login extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		$this->load->model('mlogin','',TRUE);
	}

	function index()
	{
		$this->tampil();
	}

	function tampil()
	{
		$this->load->view('vlogin');
	}

	function proses_login()
	{
		$username = $this->input->post('username');
		//echo $username;exit;
		$password = $this->input->post('password');			

		if($this->mlogin->check_user($username, $password) == TRUE){
			$data = array('username'=>$username,'login'=>TRUE);
			$this->session->set_userdata($data);
			redirect('home');
		}else{
			$this->session->set_flashdata('alert', 'Username atau password salah');
			redirect('login');	
		}
	}

	function logout()
	{
		$this->session->sess_destroy();
		redirect('login');
	}
}

